var http = require('http');
var clientHtml = require('fs').readFileSync('custom_client.html');

var plainHttpServer = http.createServer(function (req, res) {
	res.writeHead(200, {'Content-type': 'text/html'});
	res.end(clientHtml);
}).listen(8080);

var io = require('socket.io').listen(plainHttpServer);

io.set('origins', ['localhost:8080', '127.0.0.1:8080']);

io.sockets.on('connection', function (socket) {
	socket.emit('hello', 'socket.io!');

	socket.on('helloback', function (from) {
		console.log('Recieved a helloback from ' + from);
	});
});